<?php

class ExpressController extends Controller {
	public function searchAction() {
		$data = [];
		$data['com'] = Request::getParams('expressCom');
		$data['no'] = Request::getParams('expressNo');
		if (!$data['com'] || !$data['no']) {
			Response::ajax(NORMAL_ERROR, '参数传递有误,查看失败');
		}
		$data['key'] = Configure::get('juhe.key');
		$data['dtype'] = 'json';
		$result = Curl::get(Configure::get('juhe.expressSearch'), $data);
		if (!$result) {
			Response::ajax(NORMAL_ERROR, '订单查询失败,请稍后再试');
		}
		$result = json_decode($result, true);
		$data = [];
		if ($result && isset($result['resultcode']) && $result['resultcode'] == 200) {
			Response::ajax(200, 'success', $result['result']);
		}
		Response::ajax(NORMAL_ERROR, '订单查询失败,请稍后再试');
	}

	public function comAction() {
		$data = [];
		$result = self::model('order')->getExpressCom();
		if ($result) {
			Response::ajax(200, 'success', $result);
		}
		Response::ajax(NORMAL_ERROR, '查询失败,请稍后再试');
	}
}